package com.wk.masterNode;

import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ConcurrentHashMap;

import com.wk.job.Job;
import com.wk.net.connector.SocketServer;

/**
 * 负责接收客户端发过来的任务完成度信息。
 * 1. 初始化Socket连接。等待客户端报告。
 * 2. 接收报告反馈成功接收。
 * 3. 更新job完成度。
 * 
 * @author wkhua
 *
 */
public class JobMonitorMaster implements Runnable{
	private ConcurrentHashMap<String,Job> distributedJobs = null;
	ServerSocket server =null;
	
	private final int PORT=8082;
	/**
	 * 初始化已分发任务列表。
	 * @param distributedJobs
	 */
	public JobMonitorMaster(ConcurrentHashMap<String,Job> distributedJobs) {
		this.distributedJobs = distributedJobs;
		initJobMonitor();
	}

	private void initJobMonitor() {
		try {
			server = new ServerSocket(PORT);
			Socket client = server.accept();
			DataInputStream dataInputStream = new DataInputStream(client.getInputStream());
			DataOutputStream dataOutputStream = new DataOutputStream(client.getOutputStream());
			
			
			client.getOutputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void run() {

		
	}
}
